//
//  UIBarButtonItem+Extension.m
//  gdemm
//
//  Created by 乔明超 on 16/9/22.
//  Copyright © 2016年 Goldencis. All rights reserved.
//



@implementation UIBarButtonItem (Extension)
+ (UIBarButtonItem *)itemWithTarget:(id)target action:(SEL)action image:(NSString *)image highImage:(NSString *)highImage
{
    
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    // 设置图片
    [btn setBackgroundImage:[Utils getImageByDevce:image] forState:UIControlStateNormal];
    [btn setBackgroundImage:[Utils getImageByDevce:highImage] forState:UIControlStateHighlighted];
    // 设置尺寸
    if ([DeviceTypeJudge isPadDeviceType]) {
          btn.size = CGSizeMake(20, 20);
    }else{
         btn.size = CGSizeMake(16, 16);
    }
  
    btn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
    btn.imageEdgeInsets = UIEdgeInsetsMake(0, -20, 0, 0);
    return [[UIBarButtonItem alloc] initWithCustomView:btn];
}

@end
